package com.otitan.la.forest.system.util;

import org.apache.shiro.crypto.hash.SimpleHash;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * @Description: java类作用描述
 * @Author: jiachangsen
 * @CreateDate: 2020/09/17 19:57
 * @UpdateUser: jiachangsen
 * @UpdateDate: 2020/09/17 19:57
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public class AutoCommonUtil {
    
    /**
     * 获取 HttpServletRequest
     * @author jiachangsen
     * @param []
     * @return javax.servlet.http.HttpServletRequest
     * @exception 
     * @date 2020/09/17 19:58
     */
    public static HttpServletRequest getHttpServletRequest() {
        // 获取用户信息
        ServletRequestAttributes ra = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        return ra.getRequest();
    }

    /**
     * 字符串加密
     * @author jiachangsen
     * @param []
     * @return java.lang.String
     * @exception
     * @date 2020/09/17 20:01
     */
    public static String encryption(String salt, String password){
        return new SimpleHash("MD5", password, salt, 1024).toHex();
    }
}
